# coding:utf-8
import math
from typing import Union, TypeVar, Generic, Sequence, Dict

from pydantic import BaseModel, Field
from fastapi import Query

T = TypeVar("T")
C = TypeVar("C")


class UnifyResponse(BaseModel, Generic[T]):
    code: int = Field(default=200, description='状态码')
    message: str = Field(default='success', description='信息')
    data: T = Field(description='结果集')


def empty_to_none(v: str) -> Union[str, None]:
    """替换空字符为None"""
    if v == '':
        return None
    return v
